import request from "./request";

interface ResultType<T> {
  code: number;
  message: string;
  data: T;
}
interface queryAllType {
  subject: string;
  username: string;
  class_id: number | string;
  type: number | string;
}
// 查询所有教师
export function queryTeacherAll(params:queryAllType) {
  interface TeacherResult{
    total: number;
    teacherList: [];
  }
  return request<TeacherResult, ResultType<TeacherResult>>({
    url: '/teacher/all',
    method: 'get',
    params,
  })
}
// 删除教师
export function deleteTeacher(id:number) {
  return request<[], ResultType<[]>>({
    url: '/teacher/delete',
    method: 'post',
    data: {
      id
    }
  })
}

interface addTeacherType {
  user_id: number | string;
  class_id: number | string;
  subject: string;
}
// 添加教师
export function addTeacher(data:addTeacherType) {
  return request<[], ResultType<[]>>({
    url: '/teacher/add',
    method: 'post',
    data
  })
}

interface updateTeacherType {
  id: number | string;
  user_id: number | string;
  class_id: number | string;
  subject: string;
}
// 修改教师
export function updateTeacher(data: updateTeacherType) {
  return request<[], ResultType<[]>>({
    url: '/teacher/update',
    method: 'post',
    data,
  })
}
